package com.study.zzedu.demo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;

import com.androidkun.xtablayout.XTabLayout;
import com.study.zzedu.R;
import com.study.zzedu.base.BaseActivity;
import com.study.zzedu.demo.adapter.CommonTabPagerAdapter;

import java.util.Arrays;


public class MainActivity extends BaseActivity implements CommonTabPagerAdapter.TabPagerListener {

    Toolbar toolbar;
    CollapsingToolbarLayout collapsingToolbar;
    XTabLayout tabLayout;
    AppBarLayout appbar;
    ViewPager viewpager;

    private CommonTabPagerAdapter adapter;

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentLayout(R.layout.activity_main1);
        setTitleBlue("马克思主义哲学");
        collapsingToolbar = findViewById(R.id.collapsingToolbar);
        tabLayout = findViewById(R.id.tab);
        appbar = findViewById(R.id.appbar);
        viewpager = findViewById(R.id.viewpager);
        collapsingToolbar.setTitle("马克思主义哲学");
        collapsingToolbar.setExpandedTitleColor(Color.parseColor("#00ffffff"));//设置还没收缩时状态下字体颜色
        collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);//设置收缩后Toolbar上字体的
        adapter = new CommonTabPagerAdapter(getSupportFragmentManager()
                , 4, Arrays.asList("美食", "电影", "玩乐", "评价"), this);
        adapter.setListener(this);
        viewpager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    public Fragment getFragment(int position) {
        return DemoFragment.newInstance(position);
    }

}
